<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-商品列表">
</@frame.head>
<link rel="stylesheet" type="text/css" href="${contextPath}/resources/css/search_table.css" />
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理中心 <span class="c-gray en">&gt;</span>文章管理 <span class="c-gray en">&gt;</span>站内信管理<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
<form method="post" name="query_order_form"  id="query_order" action="${contextPath}/letter/letter_list" >    
   <input type="hidden" name="page" value="${pagination.pageNo}"  id="page" />                       
    <div class="text-c">
         <table class="table search_table">
                <tr>
                    <td>标题 ：</td>
                    <td>
                        <input id="title" value="${messageQo.title}" class="input-text radius" placeholder="" name="title"/>
                    </td>
              		<td>创建人 ：</td>
                    <td>
                        <input id="userName" value="${messageQo.userName}" class="input-text radius" placeholder="" name="userName"/>
                    </td>
                    <td>日期范围：</td>
                    <td>
                        <input type="text" value="<#if messageQo.createDateStart?? >${messageQo.createDateStart?date}</#if>" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}',readOnly : true })" id="datemin" name="createDateStart" class="input-text Wdate" style="width:45%;" >
                        ~
                        <input type="text" value="<#if messageQo.createDateEnd?? >${messageQo.createDateEnd?date}</#if>" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' ,readOnly : true})" id="datemax" name="createDateEnd" class="input-text Wdate" style="width:45%;">
                    </td>
                </tr>
                 <tr>
                 	<td>信件状态 ：</td>
                    <td>
                      <span class="select-box">
                        <select class="select" id="chooseStatus" name="status">
                        	<option value="">--请选择状态--</option>
                        	<#if statusMap??>
                        	  <#list statusMap?keys as key>
                 				 <option value="${key}" <#if key==messageQo.status>selected="selected"</#if> >${statusMap["${key}"]}</option> 
          					 </#list>
							</#if>
                        </select>
                      </span>
                    </td>
                    <td></td>
                 	<td colspan="3" >
                 	  <button type="button" class="btn btn-success radius" onclick="search()"><i class="Hui-iconfont">&#xe665;</i> 查询</button>
           			  <button type="button" class="btn btn-success radius" onclick="toEmpty()"><i class="Hui-iconfont">&#xe68f;</i> 重置</button>
                	</td>
                </tr>
            </table>
           
    </div>
    		     
</form>

    <div class="cl pd-5 bg-1 bk-gray mt-20"> 
  
    
    <span class="r">共有数据：<strong> ${pagination.totalCount} </strong> 条</span> </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr   class="text-c">
            <!-- <th width="45px">
            <input  type="checkbox" id="selectAll" disabled="disabled" onclick="checkAll()"/>
            </th> -->
            <th >标题</th>
            <th >状态</th>
            <th >创建人</th>
            <th >创建时间</th>
            <th >发送时间</th>
            <th >接收时间</th>
            <th >操作</th>
        </tr>
        </thead>
        <tbody>
       <#if pagination.list?? && (pagination.list?size &gt; 0) >
        <#list pagination.list as msgs> 
        	 <tr class="text-c">
        	   	<td > ${msgs.title}  </td>
        	   	<td> 
					<#if msgs.status?? && statusMap??>
							${statusMap[msgs.status]}
					</#if>
        	   	 </td>
        	   	<td >
        	   	 
        	   		<#if msgs.senderUserId?? && userMap??>
							${userMap[msgs.senderUserId?c]}
							
					</#if>
        	    
        	       <input type="hidden" value='${msgs.content}' id="content${msgs_index}">
        	
        	   </td>
        	   <td >
        	   <#if  msgs.createDate??>
        	     	${msgs.createDate?datetime}
				</#if>
        	   </td>
        	   <td>
 				<#if  msgs.sendDate??>
        	     	${msgs.sendDate?datetime}
				</#if>
        	   </td>
        	   <td >
        	   <#if  msgs.receiveDate??>
        	     	${msgs.receiveDate?datetime}
				</#if>
        	     
        	   </td>
        		<td>
        		   <a title="详情" href="javascript:;"    onclick="dio_result(${msgs_index})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe665;</i></a>
        		   <a title="删除" href="javascript:;"    onclick="del_result(${msgs.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
        		  <#if msgs.status ==1>  <a title="编辑" href="javascript:;"    onclick="edit_result(${msgs.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a></#if>
        		  <#if msgs.status ==1> <a title="发送" href="javascript:;"    onclick="send_result(${msgs.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe603;</i></a></#if>
        		  
        		   
        		</td>
        	 </tr>
      </#list>
      	 <tr> <td colspan="7" style="text-align: right;"> <button type="button" class="btn btn-success"   onclick="showAddleter()" ><i class="Hui-iconfont">&#xe600;</i> 添加</button>
                	</td></tr>
      </#if>
     </tbody>
    </table>
    <div id="biuuu_city" style="padding-top: 10px;float: right"></div>
</div>
<@frame.end "default">
</@frame.end>

<script type="text/javascript" src="${contextPath}/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/letter/letter_list.js"></script>
<script type="text/javascript">
var path="${contextPath}";

laypage({
    cont: 'biuuu_city',//容器。值支持id名、原生dom对象，jquery对象。
    pages: ${pagination.totalPage},//通过后台拿到的总页数
    curr:  ${pagination.pageNo} || 1, //当前页
    skip: true, //是否开启跳页
	first: 1, //将首页显示为数字1,。若不显示，设置false即可
	last: ${pagination.totalPage}, //将尾页显示为总页数。若不显示，设置false即可
    jump: function(obj , first){//触发分页后的回调
        if(!first){ //点击跳页触发函数;当前页为obj.curr
          $(page).val(obj.curr);//获取点击的页码
          $(query_order_form).submit();
        }
    }
})  



function showAddleter(){
var path = '${contextPath}'	;
   
    var index = layer.open({
    type: 2,
    title: '站内信添加',
    maxmin: true,
    scrollbar: false,
    content: path+"/letter/letter_insert_index",
    area: ['580px', '450px']
    });
    
    
}

function edit_result(id){
	var path = '${contextPath}'	;
	   
    var index = layer.open({
    type: 2,
    title: '站内信添加',
    maxmin: true,
    scrollbar: false,
    content: path+"/letter/letter_edit_index?id="+id,
    area: ['580px', '450px']
    });
  
	
}


function send_result(id){
	var path = '${contextPath}'	;
	layer.confirm("是否发送信息？",function(){
		 var url = path+"/letter/letter_send" ;	
		$.ajax({
	 		url:url,
	 		data:{"id":id}, 
	 		type:"post",
	 		dataType:"text",
	 		success:function(message){
	 			
	 			if(message!="-1"){
	 				layer.msg("发送成功!" ,{icon:1,time:1500},function(){
	 					
	 					$("#query_order").submit();
	 				});
	 				
	 			}else{
	 				layer.msg('发送失败！',{icon:1,time:1000},function(){});
	 			}
	 			
	 		},
	 		error:function(){
	 			layer.msg('发送失败!',{icon:1,time:1000},function(){});
	 			$("#"+no).show();
	 		}
	 	});	
	});
}    

</script>
</body>

</html>
 
